package com.czk.consumer;

import com.czk.framework.ProxyFactory;
import com.czk.provider.api.HelloService;

import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/4/14 17:08
 */
public class Consumer {
    public static void main(String[] args) {
        String protocol = "dubbo";
        // 随机协议
        int i = ThreadLocalRandom.current().nextInt(2);
        System.out.println(i);
        // 拿到代理对象
        HelloService helloService = ProxyFactory.getProxy(HelloService.class, protocol);
        // 调用方法
        String hello = helloService.print();
        System.out.println(hello);
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
